import { defineStore } from 'pinia'
import { ref } from 'vue'

const initState: IOrderConfig = {
  /** 是否自动生成单号 */
  autoOrderNo: true,
  /** 单号中是否增加设备唯一标识 */
  orderNoInDevice: false,
}

export const useOrderConfigStore = defineStore(
  'orderconfig',
  () => {
    const orderConfig = ref<IOrderConfig>({ ...initState })

    const setConfig = (val: IOrderConfig) => {
      orderConfig.value = val
    }

    const reset = () => {
      orderConfig.value = { ...initState }
    }

    return {
      orderConfig,
      setConfig,
      reset,
    }
  },
  {
    persist: true,
  },
)
